#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

int main()
{
	FILE *fp = fopen("test1", "r");
	char buf[32] = {0};
	char buf2[32] = {0};
	int i = 0;

	fseek(fp, 0, SEEK_END);

	i = 0;
	i = ftell(fp);
	printf("file len is %d\n", i);
	
	fseek(fp, 0, SEEK_SET);
	//rewind(fp);

	if (i < 32) 
	{
		fgets(buf, i, fp);
		printf("jb %s\n", buf);

		rewind(fp);
		fread(buf2, 1, i, fp);
		printf("%s\n", buf2);
	}
	else { 
		fgets(buf, 32, fp);
		printf("js %s\n", buf);

		rewind(fp);
		fread(buf2, 32-1, 1, fp);
		printf("%s\n", buf2);
	}

	return 0;
}
